<?php
/**
 * DynaGrid - The PHP datagrid
 *
 * @package    DynaGrid
 * @author     $Author: keesschepers $
 * @version    $Id: Header.php 15 2011-02-15 17:07:57Z keesschepers $
 */

class DynaGrid_HTML_Table_Column_Header extends DynaGrid_HTML_Table_Column {
	protected $tagname = 'th';	
	protected $title;
	/**
	 * Url object
	 *
	 * @var DynaGrid_Url
	 */
	protected $url;
	/**
	 * This is the database column name where this visual column is sorted on.
	 *
	 * @var string
	 */
	protected $orderField;
	public function __construct($name) {
		$this->title = $name;
		$this->orderField = $name;
		$this->url = new DynaGrid_Url($_SERVER['QUERY_STRING']);
		parent::__construct($name);
	}
	/**
	 * Set a table field where this column is sorted on.
	 *
	 * @param string $field
	 */
	public function setOrderField($field) {
		$this->orderField = $field;
	}
	public function setTitle($title) {
		$this->title = $title;
	}
	public function getHTML() {		
//		$this->innerHTML = $this->title.' ';
		
    $this->url->orderfield = $this->orderField;    
    $this->url->orderway = 'DESC';		
		
		$this->innerHTML  = '<div class="grid-sort-none"><a href="' . $this->url->getQueryString() . '">' . $this->title . '</a></div>';
		$this->innerHTML .= '<div class="grid-col-resize">-</div>';
		
		
//		$this->innerHTML .= 'Desc</a> ';
		
		$this->url->orderway = 'ASC';
//		$this->innerHTML .= '<a href="'.$this->url->getQueryString().'">Asc</a>';
		
		return parent::getHTML();
	}
}